<template>
  <div id="AddGoods">
<<<<<<< HEAD
   
      <h2>新增商品</h2>
       <el-form :model="productForm" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="商品编号" required>
              <el-input v-model="productForm.code" placeholder="请输入商品编号"></el-input>
=======
    <h2>新增商品</h2>
    <el-form :model="productForm" label-width="120px">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="商品编号" required>
            <el-input
              v-model="productForm.code"
              placeholder="请输入商品编号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="商品名称" required>
            <el-input
              v-model="productForm.name"
              placeholder="请输入商品名称"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="商品条码">
            <el-input
              v-model="productForm.barcode"
              placeholder="请输入商品条码"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="继承编号规则">
            <el-checkbox v-model="productForm.inheritCodeRule"
              >继承当前编号规则</el-checkbox
            >
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="规格型号">
            <el-input
              v-model="productForm.specification"
              placeholder="请输入规格型号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="首选仓库">
            <el-select
              v-model="productForm.defaultWarehouse"
              placeholder="请选择首选仓库"
            >
              <el-option label="仓库1" value="仓库1"></el-option>
              <el-option label="仓库2" value="仓库2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="商品类别">
            <el-select
              v-model="productForm.category"
              placeholder="请选择商品类别"
            >
              <el-option label="类别1" :value="类别1"></el-option>
              <el-option label="类别2" value="类别2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="计量单位">
            <el-select v-model="productForm.unit" placeholder="请选择计量单位">
              <el-option label=""></el-option>
              <el-option label="单位1" value="单位1"></el-option>
              <el-option label="单位2" value="单位2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="多单位">
            <el-checkbox v-model="productForm.multiUnit">多单位</el-checkbox>
          </el-form-item>
          <el-form-item label="首选入库单位" v-show="productForm.multiUnit">
            <el-select placeholder="请选择" required>
              <el-option value="">（空）</el-option>
              <!-- 其他选项 -->
            </el-select>
          </el-form-item>
          <el-form-item label="首选出库单位" v-show="productForm.multiUnit">
            <el-select placeholder="请选择" required>
              <el-option value="">（空）</el-option>
              <!-- 其他选项 -->
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="产地">
            <el-input
              v-model="productForm.origin"
              placeholder="请输入产地"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="注册证号">
            <el-input
              v-model="productForm.registrationNumber"
              placeholder="请输入注册证号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="生产许可证">
            <el-input
              v-model="productForm.productionLicense"
              placeholder="请输入生产许可证"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="默认供应商">
            <el-input
              v-model="productForm.defaultSupplier"
              placeholder="请输入默认供应商"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="品牌">
            <el-select v-model="productForm.brand" placeholder="请选择品牌">
              <el-option label="品牌1" value="品牌1"></el-option>
              <el-option label="品牌2" value="品牌2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="PLU码">
            <el-input
              v-model="productForm.pluCode"
              placeholder="请输入1-99999数字"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="重量(kg)">
            <el-input
              v-model="productForm.weight"
              placeholder="请输入重量(kg)"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="价格1">
            <el-input></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="价格2">
            <el-input></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="价格3">
            <el-input></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="商品税率">
            <el-input></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否免税">
            <el-select>
              <el-option label="是" value="是"></el-option>
              <el-option label="否" value="否"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="商品开票名称">
            <el-input></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <h5 style="position: relative; left: 100px">增加商品图片</h5>
      <el-upload
        class="avatar-uploader"
        action="https://jsonplaceholder.typicode.com/posts/"
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload"
      >
        <img
          v-if="imageUrl"
          :src="imageUrl"
          class="avatar"
          alt="增加商品图片"
        />
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>

      <h2>新增商品</h2>
      <el-form :model="productForm" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="商品编号" required>
              <el-input
                v-model="productForm.code"
                placeholder="请输入商品编号"
              ></el-input>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商品名称" required>
<<<<<<< HEAD
              <el-input v-model="productForm.name" placeholder="请输入商品名称"></el-input>
=======
              <el-input
                v-model="productForm.name"
                placeholder="请输入商品名称"
              ></el-input>
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商品条码">
<<<<<<< HEAD
              <el-input v-model="productForm.barcode" placeholder="请输入商品条码"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="继承当前编号规则">
              <el-checkbox v-model="productForm.inheritCodeRule">继承当前编号规则</el-checkbox>
            </el-form-item>
          </el-col>
          
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="规格型号">
              <el-input v-model="productForm.specification" placeholder="请输入规格型号"></el-input>
            </el-form-item>
          </el-col>
             <el-col :span="6">
      <el-form-item label="首选仓库">
        <el-select v-model="productForm.defaultWarehouse" placeholder="请选择首选仓库">
          <el-option label="仓库1" value="仓库1"></el-option>
          <el-option label="仓库2" value="仓库2"></el-option>
        </el-select>
      </el-form-item>
    </el-col>
          <el-col :span="6">
            <el-form-item label="商品类别">
              <el-select v-model="productForm.category" placeholder="请选择商品类别">
=======
              <el-input
                v-model="productForm.barcode"
                placeholder="请输入商品条码"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="继承当前编号规则">
              <el-checkbox v-model="productForm.inheritCodeRule"
                >继承当前编号规则</el-checkbox
              >
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="规格型号">
              <el-input
                v-model="productForm.specification"
                placeholder="请输入规格型号"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="首选仓库">
              <el-select
                v-model="productForm.defaultWarehouse"
                placeholder="请选择首选仓库"
              >
                <el-option label="仓库1" value="仓库1"></el-option>
                <el-option label="仓库2" value="仓库2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商品类别">
              <el-select
                v-model="productForm.category"
                placeholder="请选择商品类别"
              >
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
                <el-option label="类别1" value="类别1"></el-option>
                <el-option label="类别2" value="类别2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
<<<<<<< HEAD
       <el-row :gutter="20">
          <el-col :span="6">
      <el-form-item label="计量单位">
        <el-select v-model="productForm.unit" placeholder="请选择计量单位">
          <el-option label="单位1" value="单位1"></el-option>
          <el-option label="单位2" value="单位2"></el-option>
        </el-select>
      </el-form-item>
    </el-col>
      <el-col :span="6">
    <el-form-item label="多单位">
  <el-checkbox v-model="productForm.multiUnit">多单位</el-checkbox>
</el-form-item>
<el-form-item label="首选入库单位" v-show="productForm.multiUnit">
  <el-select placeholder="请选择" required>
    <el-option value="">（空）</el-option>
    <!-- 其他选项 -->
  </el-select>
</el-form-item>
<el-form-item label="首选出库单位" v-show="productForm.multiUnit">
  <el-select placeholder="请选择" required>
    <el-option value="">（空）</el-option>
    <!-- 其他选项 -->
  </el-select>
</el-form-item>
    </el-col>
  </el-row>
  
  <el-row :gutter="20">
  
    <el-col :span="6">
      <el-form-item label="产地">
        <el-input v-model="productForm.origin" placeholder="请输入产地"></el-input>
      </el-form-item>
    </el-col>
     <el-col :span="6">
      <el-form-item label="注册证号">
        <el-input v-model="productForm.registrationNumber" placeholder="请输入注册证号"></el-input>
      </el-form-item>
    </el-col>
    <el-col :span="6">
      <el-form-item label="生产许可证">
        <el-input v-model="productForm.productionLicense" placeholder="请输入生产许可证"></el-input>
      </el-form-item>
    </el-col>
  </el-row>
 
  <el-row :gutter="20">
    <el-col :span="6">
      <el-form-item label="默认供应商">
        <el-input v-model="productForm.defaultSupplier" placeholder="请输入默认供应商"></el-input>
      </el-form-item>
    </el-col>
    <el-col :span="6">
      <el-form-item label="品牌">
        <el-select v-model="productForm.brand" placeholder="请选择品牌">
          <el-option label="品牌1" value="品牌1"></el-option>
          <el-option label="品牌2" value="品牌2"></el-option>
        </el-select>
      </el-form-item>
    </el-col>
    <el-col :span="6">
      <el-form-item label="PLU码">
        <el-input v-model="productForm.pluCode" placeholder="请输入1-99999数字"></el-input>
      </el-form-item>
    </el-col>
     <el-col :span="6">
      <el-form-item label="重量(kg)">
        <el-input v-model="productForm.weight" placeholder="请输入重量(kg)"></el-input>
      </el-form-item>
    </el-col>
  </el-row>
  <el-row :gutter="20">
    <el-col :span="6">
      <el-form-item label="价格1">
        <el-input ></el-input>
      </el-form-item>
    </el-col>
    <el-col :span="6">
      <el-form-item label="价格2">
        <el-input  ></el-input>
      </el-form-item>
    </el-col>
     <el-col :span="6">
      <el-form-item label="价格3">
        <el-input  ></el-input>
      </el-form-item>
    </el-col>
  </el-row>
   <el-row :gutter="20">
    <el-col :span="6">
      <el-form-item label="商品税率">
        <el-input ></el-input>
      </el-form-item>
    </el-col>
    <el-col :span="6">
      <el-form-item label="是否免税">
        <el-select >
          <el-option label="是" value="是"></el-option>
          <el-option label="否" value="否"></el-option>
        </el-select>
      </el-form-item>
    </el-col>
     <el-col :span="6">
      <el-form-item label="商品开票名称">
        <el-input  ></el-input>
      </el-form-item>
    </el-col>
  </el-row>
  <h5 style="position:relative;left:100px">增加商品图片</h5>
  <el-upload
  class="avatar-uploader"
  action="https://jsonplaceholder.typicode.com/posts/"
  :show-file-list="false"
  :on-success="handleAvatarSuccess"
  :before-upload="beforeAvatarUpload">
  <img v-if="imageUrl" :src="imageUrl" class="avatar" alt="增加商品图片">
  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>

      
=======
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="计量单位">
              <el-select
                v-model="productForm.unit"
                placeholder="请选择计量单位"
              >
                <el-option label="单位1" value="单位1"></el-option>
                <el-option label="单位2" value="单位2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="多单位">
              <el-checkbox v-model="productForm.multiUnit">多单位</el-checkbox>
            </el-form-item>
            <el-form-item label="首选入库单位" v-show="productForm.multiUnit">
              <el-select placeholder="请选择" required>
                <el-option value="">（空）</el-option>
                <!-- 其他选项 -->
              </el-select>
            </el-form-item>
            <el-form-item label="首选出库单位" v-show="productForm.multiUnit">
              <el-select placeholder="请选择" required>
                <el-option value="">（空）</el-option>
                <!-- 其他选项 -->
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="产地">
              <el-input
                v-model="productForm.origin"
                placeholder="请输入产地"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="注册证号">
              <el-input
                v-model="productForm.registrationNumber"
                placeholder="请输入注册证号"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="生产许可证">
              <el-input
                v-model="productForm.productionLicense"
                placeholder="请输入生产许可证"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="默认供应商">
              <el-input
                v-model="productForm.defaultSupplier"
                placeholder="请输入默认供应商"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="品牌">
              <el-select v-model="productForm.brand" placeholder="请选择品牌">
                <el-option label="品牌1" value="品牌1"></el-option>
                <el-option label="品牌2" value="品牌2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="PLU码">
              <el-input
                v-model="productForm.pluCode"
                placeholder="请输入1-99999数字"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="重量(kg)">
              <el-input
                v-model="productForm.weight"
                placeholder="请输入重量(kg)"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="价格1">
              <el-input></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="价格2">
              <el-input></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="价格3">
              <el-input></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="商品税率">
              <el-input></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否免税">
              <el-select>
                <el-option label="是" value="是"></el-option>
                <el-option label="否" value="否"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="商品开票名称">
              <el-input></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <h5 style="position: relative; left: 100px">增加商品图片</h5>
      <el-upload
        class="avatar-uploader"
        action="https://jsonplaceholder.typicode.com/posts/"
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload"
      >
        <img
          v-if="imageUrl"
          :src="imageUrl"
          class="avatar"
          alt="增加商品图片"
        />
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>

>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
      <el-form-item>
        <el-checkbox v-model="productForm.enableWarehouseAlert"
          >仓库预警</el-checkbox
        >
      </el-form-item>
      <el-row :gutter="20" style="width: 100%; position: relative; left: 150px">
        <el-col :span="6">
          <el-form-item
            v-if="productForm.enableWarehouseAlert"
            label="最低库存"
          >
            <el-input
              v-model="productForm.minStock"
              placeholder="请输入最低库存"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item
            v-if="productForm.enableWarehouseAlert"
            label="最高库存"
          >
            <el-input
              v-model="productForm.maxStock"
              placeholder="请输入最高库存"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-checkbox v-model="showSettings">设置商品辅助属性</el-checkbox>
      </el-form-item>

      <div
        v-if="showSettings"
        style="width: 100%; position: relative; left: 150px"
      >
        <el-form-item label="商品辅助属性">
          <el-checkbox-group v-model="productForm.attributeCategories">
            <el-checkbox label="颜色" value="颜色"></el-checkbox>
            <el-checkbox label="品牌" value="品牌"></el-checkbox>
            <el-checkbox label="规格" value="规格"></el-checkbox>
            <el-checkbox label="尺码" value="尺码"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item
          v-if="productForm.attributeCategories.includes('颜色')"
          label="颜色"
        >
          <el-checkbox-group v-model="productForm.colors">
            <el-checkbox label="红" value="红"></el-checkbox>
            <el-checkbox label="绿" value="绿"></el-checkbox>
            <el-checkbox label="蓝" value="蓝"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item>
          <el-checkbox v-model="productForm.zuhe">自动建立属性组合</el-checkbox>
        </el-form-item>
        <el-button
          type="primary"
          v-if="productForm.zuhe"
          @click="generateAttributeCombinations"
          >快速生成</el-button
        >
        <el-table
          :data="attributeCombinations"
          v-if="productForm.zuhe"
          style="width: 100%"
        >
          <el-table-column prop="image" label="图片"></el-table-column>
          <el-table-column prop="color" label="颜色" required></el-table-column>
          <el-table-column
            prop="attributeCode"
            label="属性编号"
            required
          ></el-table-column>
          <el-table-column
            prop="attributeBarcode"
            label="属性条码"
          ></el-table-column>
          <el-table-column
            prop="wholesalePrice"
            label="批发价"
          ></el-table-column>
          <el-table-column
            prop="discount1"
            label="折扣率1(%)"
          ></el-table-column>
          <el-table-column prop="vipPrice" label="VIP会员价"></el-table-column>
          <el-table-column prop="retailPrice" label="零售价"></el-table-column>
          <el-table-column
            prop="discount2"
            label="折扣率2(%)"
          ></el-table-column>
          <el-table-column prop="price1" label="价格1"></el-table-column>
        </el-table>
      </div>

      <el-form-item>
        <el-checkbox v-model="productForm.enableShelfLifeManagement"
          >启用批次保质期管理</el-checkbox
        >
      </el-form-item>
      <div v-if="productForm.enableShelfLifeManagement">
        <el-row
          :gutter="20"
          style="width: 100%; position: relative; left: 150px"
        >
          <el-col :span="6">
            <el-form-item label="保质期天数">
              <el-input
                v-model="productForm.shelfLifeDays"
                placeholder="请输入保质期天数"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="报警天数">
              <el-input
                v-model="productForm.alertDays"
                placeholder="请输入报警天数"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-form-item>
        <el-checkbox v-model="productForm.enableSerialNumberManagement"
          >启用序列号管理</el-checkbox
        >
      </el-form-item>
      <el-form-item>
        <el-checkbox v-model="productForm.initialSetup">期初设置</el-checkbox>
      </el-form-item>
      <el-table
        :data="tableData"
        border
        style="width: 100%; position: relative; left: 150px"
        v-show="productForm.initialSetup"
        height="300"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="warehouse" label="仓库" width="150">
          <template slot-scope="scope">
            <el-select
              v-model="scope.row.warehouse"
              placeholder="请选择仓库"
              size="mini"
            >
              <el-option
                v-for="item in warehouseOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="batch" label="批量" width="100">
          <template slot-scope="scope">
            <el-input v-model="scope.row.batch" size="mini"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="attributes" label="属性" width="150">
          <template slot-scope="scope">
            <el-select
              v-model="scope.row.attributes"
              placeholder="请选择属性"
              size="mini"
            >
              <el-option
                v-for="item in attributesOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="initialQuantity" label="期初数量" width="100">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.initialQuantity"
              size="mini"
              type="number"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="unitCost" label="单位成本" width="100">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.unitCost"
              size="mini"
              type="number"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="totalInitialPrice" label="期初总价" width="150">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.totalInitialPrice"
              size="mini"
              type="number"
              readonly
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button size="mini" @click="addRow(scope.$index, scope.row)"
              >+</el-button
            >
            <el-button size="mini" @click="removeRow(scope.$index)"
              >-</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "AddGoods",
  data() {
    return {
<<<<<<< HEAD
=======
      brands: [],
      attributes: [],
      units: [],
      stocks: [],
      categorys: [],
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
      warehouseOptions: [
        // 仓库选项
        { value: "仓1", label: "仓1" },
        { value: "仓2", label: "仓2" },
        { value: "仓3", label: "仓3" },
      ],
      attributesOptions: [
        // 属性选项
        { value: "属性1", label: "属性1" },
        { value: "属性2", label: "属性2" },
        { value: "属性3", label: "属性3" },
      ],
      tableData: [
        {
          warehouse: "仓1",
          batch: "批1",
          attributes: "属性1",
          initialQuantity: 100,
          unitCost: 10.5,
          totalInitialPrice: 1050,
        },
      ],
<<<<<<< HEAD
      showSettings: true,
      productForm: {
        code: "",
        name: "",
        inheritCodeRule: false,
        barcode: "",
        specification: "",
        category: "",
        defaultWarehouse: "",
        unit: "",
        multiUnit: false,
        origin: "",
        registrationNumber: "",
        productionLicense: "",
        defaultSupplier: "",
        brand: "",
        pluCode: "",
        weight: "",
        dimensions: "",
        minStock: "",
        maxStock: "",
        enableWarehouseAlert: false,
        attributeCategories: [],
        colors: [],
        attributeCombinations: [],
        shelfLifeDays: "",
        alertDays: "",
        enableSerialNumberManagement: false,
        initialSetup: false,
        zuhe: false,
      },
    };
  },
  methods: {
    addRow(index, row) {
      this.tableData.splice(index + 1, 0, {
        warehouse: "",
        batch: "",
        attributes: "",
        initialQuantity: 0,
        unitCost: 0,
        totalInitialPrice: 0,
      });
    },
     generateAttributeCombinations() {
      console.log('生成属性组合');
      // 实现属性组合的生成逻辑
    },
    handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      },
    resetForm() {
      this.productForm = {
        code: '',
        name: '',
        inheritCodeRule: false,
        barcode: '',
        specification: '',
        category: '',
        defaultWarehouse: '',
        unit: '',
        multiUnit: false,
        origin: '',
        registrationNumber: '',
        productionLicense: '',
        defaultSupplier: '',
        brand: '',
        pluCode: '',
        weight: '',
        dimensions: '',
        minStock: '',
        maxStock: '',
        enableWarehouseAlert: false,
        attributeCategories: [],
        colors: [],
        attributeCombinations: [],
        shelfLifeDays: '',
        alertDays: '',
        enableSerialNumberManagement: false,
        initialSetup: false
      };
    }
   
  }
=======
      showSettings: false,
      productForm: {
        id: null, // 假设ID是由数据库自动生成的
        imagename: "",
        goodcode: "",
        goodname: "",
        barcode: "",
        specificationmodel: "",
        categoryid: null, // 假设这是类别的ID
        warehouseid: null, // 假设这是仓库的ID
        unitid: null, // 假设这是单位的ID
        multiunitid: null, // 假设这是多单位的ID
        origin: "",
        registrationnumber: "",
        productionlicense: "",
        suppliercode: "",
        brandid: null, // 假设这是品牌的ID
        weight: "",
        retailprice: "",
        wholesaleprice: "",
        vipprice: "",
        taxrate: "",
        invoicename: "",
        invoicenotes: "",
        goodattributeid: null, // 假设这是商品属性的ID
        managementmethod: "", // 假设这是管理方法的描述或标识
        shelflifedays: "",
        status: "", // 假设这是商品状态的描述或标识
        createDate: "", // 假设这是创建时间，可能不需要在表单中显示
        showSettings: true,
        productForm: {
          code: "",
          name: "",
          inheritCodeRule: false,
          barcode: "",
          specification: "",
          category: "",
          defaultWarehouse: "",
          unit: "",
          multiUnit: false,
          origin: "",
          registrationNumber: "",
          productionLicense: "",
          defaultSupplier: "",
          brand: "",
          pluCode: "",
          weight: "",
          dimensions: "",
          minStock: "",
          maxStock: "",
          enableWarehouseAlert: false,
          attributeCategories: [],
          colors: [],
          attributeCombinations: [],
          shelfLifeDays: "",
          alertDays: "",
          enableSerialNumberManagement: false,
          initialSetup: false,
          zuhe: false,
        },
      },
      methods: {
        getBrand() {
          this.axios({
            url: "/erp/goods/brand/getList",
            params: {
              pageSize: 5,
              pageNum: 1,
            },
          }).then((rs) => {
            this.brands = rs.data.pageInfo.list;
            console.log("brand", rs.data.pageInfo.list);
          });
        },
        getAttribute() {
          this.axios({
            url: "/erp/goods/attributes/getList",
            params: {
              pageSize: 5,
              pageNum: 1,
            },
          }).then((rs) => {
            this.attributes = rs.data.list;
            console.log("attribute", rs.data.list);
          });
        },
        getUnit() {
          this.axios({
            url: "/erp/goods/basicUnit/getList",
            params: {
              pageSize: 5,
              pageNum: 1,
            },
          }).then((rs) => {
            this.units = rs.data.list;
            console.log("unit", rs.data.list);
          });
        },
        // getStock() {
        //   this.axios({
        //     url: "/erp/goods/stock/getList",
        //     params: {
        //       pageSize: 5,
        //       pageNum: 1,
        //     },
        //   }).then((rs) => {
        //     this.units = rs.data.pageInfo.list;
        //   });
        // },
        getCategory() {
          this.axios({
            url: "/erp/goods/category/getList",
            params: {
              pageSize: 5,
              pageNum: 1,
            },
          }).then((rs) => {
            this.categorys = rs.data.list;
            console.log("category", rs.data.list);
          });
        },
        addRow(index, row) {
          this.tableData.splice(index + 1, 0, {
            warehouse: "",
            batch: "",
            attributes: "",
            initialQuantity: 0,
            unitCost: 0,
            totalInitialPrice: 0,
          });
        },
        generateAttributeCombinations() {
          console.log("生成属性组合");
          // 实现属性组合的生成逻辑
        },
        handleAvatarSuccess(res, file) {
          this.imageUrl = URL.createObjectURL(file.raw);
        },
        beforeAvatarUpload(file) {
          const isJPG = file.type === "image/jpeg";
          const isLt2M = file.size / 1024 / 1024 < 2;

          if (!isJPG) {
            this.$message.error("上传头像图片只能是 JPG 格式!");
          }
          if (!isLt2M) {
            this.$message.error("上传头像图片大小不能超过 2MB!");
          }
          return isJPG && isLt2M;
        },
      },
      created() {
        this.getAttribute();
        this.getBrand();
        this.getCategory();
        this.getUnit();
      },
    };
  },
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
};
</script>

<style scoped>
.table-header-row {
  background-color: #f5f7fa; /* 例如，使用浅灰色作为背景 */
}
.el-table th,
.el-table td {
  text-align: center;
}
#AddProduct {
  padding: 20px;
}

.box-card {
  width: 800px;
  margin: 0 auto;
}

h2,
h3 {
  margin-bottom: 20px;
}
<<<<<<< HEAD
 .avatar-uploader .el-upload {
   
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    background-color: gray; /* 设置背景颜色为灰色 */
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    position: relative;
    left: 100px;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
=======
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  background-color: gray; /* 设置背景颜色为灰色 */
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  position: relative;
  left: 100px;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  background-color: gray; /* 设置背景颜色为灰色 */
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  position: relative;
  left: 100px;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
</style>